package com.nhncorp.yammer.bean;

public enum PostType {
	UPDATE(0), QUESTION(1), LINK(2), POLL(3), EVENT(4);

	private int postType;

	PostType(int postType) {
		this.postType = postType;
	}

	public String toString() {
		return String.valueOf(postType);
	}

	public int getValue() {
		return this.postType;
	}

	public static PostType fromValue(int postType) {
		for (PostType type : PostType.values()) {
			if (type.getValue() == postType) {
				return type;
			}
		}

		return null;
	}

	public static PostType fromValue(Object postType) {
		if (postType == null) {
			return null;
		}
		for (PostType type : PostType.values()) {
			if (type.getValue() == Integer.parseInt(String.valueOf(postType))) {
				return type;
			}
		}

		return null;
	}
}
